// 依赖的第三方库的样式
import 'element-plus/dist/index.css'
import 'vant/lib/index.css'
import 'vue3-perfect-scrollbar/style.css';
import 'tippy.js/dist/tippy.css'; // 引入样式

import _ from 'lodash'
import {createApp, resolveComponent} from 'vue'
import * as Vue from 'vue'
// import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import Vant from 'vant';
import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar';
import VueGridLayout from 'vue3-grid-layout-next';
// import { plugin as VueTippy } from 'vue-tippy'
import VueTippy from 'vue-tippy';

// import VueTippy from 'vue-tippy'
// import VueCodemirror from 'vue-codemirror'
// import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import jzlUtils from '@jzl/utils'
import jzlApi from '@jzl/api'
import jzlComps from '@jzl/comps'
import jzlCompsMg from '@jzl/comps-mg'
import { errorHandler, successHandler } from "@/common/axios-handlers.js";
import { setupStore } from "@/store";
import initPlatformConfig from './config/index.js';

import App from './App.vue'
import router from './router'

// 自定义样式，放后面，优先级最高，覆盖其他库通用样式
import './assets/css/index.scss'
import './assets/css/tailwind.css'

const app = createApp(App)

// app.use(createPinia())
setupStore(app)
// app.use(VueCodemirror)
app.use(router)
app.use(jzlUtils, {
  clientType: import.meta.env.VITE_CLIENT_TYPE,
})
app.use(jzlApi, {
  baseUrl: import.meta.env.VITE_APP_URL,
  errorHandler,
  successHandler,
  // axios,
  // getToken,
  // getConfig,
})
app.use(jzlComps)
app.use(jzlCompsMg)
app.use(ElementPlus, { locale: zhCn });
app.use(Vant);
app.use(PerfectScrollbarPlugin);
app.use(VueGridLayout);
app.use(VueTippy, {
  directive: 'tippy', // => v-tippy
  component: 'tippy', // => <tippy/>
  componentSingleton: 'tippy-singleton', // => <tippy-singleton/>,
  defaultProps: {
    // placement: 'auto-end',
    allowHTML: true,
  }
});

/*for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}*/
initPlatformConfig(app);

app.mount('#app')

if (typeof window !== 'undefined') {
  window.vue = Vue;
}
// if(!window._) window._ = _;
